Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 17, 2025

This PR adds complete macOS support to the snapx deployment tool, enabling cross-platform application deployment on macOS alongside existing Windows and Linux support.

Overview

The implementation follows the existing platform architecture pattern, extending the current Windows/Linux support to include native macOS functionality. All changes are backward compatible and don't affect existing Windows or Linux deployments.

Key Features Added

macOS Platform Integration

  • Added OSPlatform.OSX detection throughout the C# codebase
  • Implemented SnapOsSpecialFoldersMacOS with proper macOS folder paths:
    • StartupDirectory: ~/Library/LaunchAgents for autostart applications
    • StartMenu: /Applications for installed applications
    • Standard macOS ApplicationData and cache directories

Native macOS Application Support

  • App Bundle Creation: Generates proper .app bundles with Info.plist files
  • LaunchAgent Integration: Creates plist files for system startup integration
  • macOS Conventions: Follows Apple's guidelines for application structure and metadata

Cross-Platform Build System

  • Added osx-x64 and osx-arm64 Runtime Identifiers (RIDs)
  • Updated build scripts (bootstrap.ps1, build.ps1) for macOS compilation
  • CMake configuration with proper Apple platform detection
  • Native library support using .dylib extensions (vs .so on Linux)

C++ Platform Abstraction Layer (PAL)

  • Added PAL_PLATFORM_MACOS platform define
  • macOS-specific includes and system calls
  • Shared Unix-like functionality where appropriate
  • Updated all platform detection functions (pal_is_macos(), etc.)

GitHub Actions CI/CD Support

  • Added complete macos job with macos-latest runners
  • Configured matrix builds for osx-x64 and osx-arm64 architectures
  • Integrated with existing build system using Bootstrap-Unix target
  • Added native and .NET unit test execution for macOS
  • Configured artifact collection with macOS-specific .dylib extensions
  • Updated publish workflow dependencies to include macOS builds

Technical Implementation

The solution extends the existing ISnapOsImpl interface with a new SnapOsMacOS class that provides:

// Platform-specific folder paths
public override string StartupDirectory => $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/Library/LaunchAgents";
public override string StartMenu => "/Applications";

// macOS app bundle creation
await CreateMacOSAppBundle(shortcutDescription, logger, cancellationToken);

// LaunchAgent plist for autostart
await CreateLaunchAgentPlist(shortcutDescription, logger, cancellationToken);

The C++ PAL layer properly detects macOS at compile time:

#elif defined(PAL_PLATFORM_MACOS)
#include <mach-o/dyld.h>
// macOS-specific implementations
#endif

Code Quality & Standards

  • File-scoped Namespaces: All new C# test files use modern file-scoped namespace syntax (namespace Snap.Tests.AnyOS.MacOS;)
  • Target Framework Consistency: Maintains original .NET 10.0 target frameworks to prevent breaking existing builds
  • Code Style: Follows existing project conventions and patterns established for Windows/Linux support

Merge Integration

Successfully resolved merge conflicts with the develop branch while maintaining full macOS functionality:

  • CMake Configuration: Preserved Apple platform detection with if(APPLE) condition
  • PAL Functions: Integrated macOS support in pal_sleep_ms() and added pal_is_macos() function
  • Platform Detection: Updated pal_is_unknown_os() to recognize macOS as a known platform
  • Build System: Maintained compatibility with updated build workflows and tooling

Testing

  • Created comprehensive unit tests for macOS functionality (conditionally compiled with #if PLATFORM_MACOSX)
  • Verified existing Windows/Linux functionality remains intact
  • Validated CLI tool builds and runs correctly
  • Confirmed native C++ components compile successfully with macOS changes
  • Verified successful integration with latest develop branch changes
  • Added CI/CD pipeline testing for macOS builds in GitHub Actions

Compatibility

  • Backward Compatible: No breaking changes to existing Windows/Linux deployments
  • Runtime Detection: Automatically activates macOS features when running on macOS
  • Build System: Integrates seamlessly with existing build processes and latest develop branch updates
  • Dependencies: Uses existing .NET and system libraries
  • CI/CD: Full GitHub Actions integration with automated testing and artifact publishing

This implementation enables snapx to deploy applications natively on macOS with proper system integration, app bundle creation, autostart capabilities, and continuous integration support while maintaining full compatibility with existing Windows and Linux deployments.

Fixes #429.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits September 17, 2025 08:40
Co-authored-by: peters <869+peters@users.noreply.github.com>
Co-authored-by: peters <869+peters@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for macOS Add comprehensive macOS support to snapx deployment tool Sep 17, 2025
Copilot AI requested a review from peters September 17, 2025 08:48
@peters
Copy link
Collaborator

peters commented Sep 19, 2025

@copilot Fix merge conflicts

Co-authored-by: peters <869+peters@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Sep 19, 2025

@copilot Fix merge conflicts

Merge conflicts have been successfully resolved in commit 2e66342. The macOS support changes have been integrated with the latest develop branch while maintaining full compatibility with existing Windows and Linux functionality.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aka.ms
    • Triggering command: curl -I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

… add macOS GitHub Actions

Co-authored-by: peters <869+peters@users.noreply.github.com>
Copilot AI requested a review from peters September 19, 2025 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for macOS

2 participants